<template>
  <div>

    <el-table
        :data="tableData"
        border
        style="width: 100% ">
      <el-table-column
          fixed
          prop="productId"
          label="ProductID"
          width="150">
      </el-table-column>
      <el-table-column
          prop="categoryId"
          label="Category"
          width="150">
      </el-table-column>
      <el-table-column
          prop="name"
          label="Name"
          width="160">
      </el-table-column>
      <el-table-column
          label="操作"
          width="90">
        <template slot-scope="scope">
          <el-button @click="edit(scope.row)" type="text" size="small">查看或修改</el-button>

        </template>
      </el-table-column>
    </el-table>
    <!--实现分页查询-->
    <el-pagination
        background
        layout="prev, pager, next"
        page-size="8"
        :total=counts
        @current-change="page">
    </el-pagination>

  </div>

</template>

<script>
export default {
  methods: {

    edit(row) {
      this.$router.push({
        path: '/productupdate',
        query: {
          productId: row.productId,
          categoryId: row.categoryId,
          name: row.name,

        }
      })

    },

    //分页
    page(currentPage) {
      //alert(currentPage)
      const _this = this
      //此处需要查询item的全部信息
      axios({
        method: "GET",
        url: 'http://115.29.176.82:8081/manager/api/product',
        params: {
          size: 8,
          page: currentPage,

        }
      }).then(function (resp) {
        _this.tableData = (resp.data.data.list)
      })
    },




  },
    created() {
      const _this = this
      //此处需要查询item的全部信息
      axios({
        method: "GET",
        url: 'http://115.29.176.82:8081/manager/api/product',
        params: {
          size: 8,
          page:1
        }
      }).then(function (resp) {
        _this.counts=resp.data.data.counts
        _this.tableData = (resp.data.data.list)
      })

    },
    data() {
      return {
        category: '',
        tableData:[],
        counts:null
      }
    },


}
</script>